package algorithm.poj.p3000;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLDecoder;


/**
 * 分析：
 * 
 * 实现：
 * 
 * 经验和教训：
 * 
 * 
 * @author wong.tong@gmail.com
 *
 */
public class P3748 {

	public static void main(String[] args) throws Exception {

		InputStream input = null;
		if (false) {
			input = System.in;
		} else {
			URL url = P3748.class.getResource("P3748.txt");
			File file = new File(URLDecoder.decode(url.getPath(), "UTF-8"));
			input = new FileInputStream(file);
		}
		
		BufferedReader stdin = new BufferedReader(new InputStreamReader(input));

		String line = stdin.readLine();
		String[] tmp = line.trim().split(",");
		String R = tmp[0];
		int X = Integer.valueOf(tmp[1]);
		int Y = Integer.valueOf(tmp[2]);

		String[] map = {
				"0000", "0001", "0010", "0011","0100", "0101", "0110", "0111",
				"1000", "1001", "1010", "1011","1100", "1101", "1110", "1111"
		};
		while (R.length() < 8) R = "0" + R;
		String t = "";
		for (int i = 0; i < 8; i ++) {
			char c = R.charAt(i);
			if (c >= '0' && c <= '9') {
				t += map[c-'0'];
			} else {
				t += map[c-'a'+10];
			}
		}
//		System.out.println(t);
		
		char[] cs = t.toCharArray();
		cs[31-X] = '0';
		cs[31-Y] = '1';
		cs[32-Y] = '1';
		cs[33-Y] = '0';
//		System.out.println(new String(cs));
		
		char[] r = new char[8];
		for (int i = 0; i < cs.length; i += 4) {
			int a = ((cs[i]-'0')<<3) + ((cs[i+1]-'0')<<2) 
					+ ((cs[i+2]-'0')<<1) + (cs[i+3]-'0');
			if (a < 10) {
				r[i/4] = (char)(a+'0');
			} else {
				r[i/4] = (char)(a-10+'a');
			}
		}
//		System.out.println(new String(r));
		
		int index = 0;
		while (true) {
			if (r[index ++] != '0') break;
		}
		
		String ret = "";
		for (int i = index-1; i < 8; i ++) ret += r[i];
		System.out.println(ret);
	}
	
}